package com.celan.year2023.month01.day26;

import java.util.Arrays;

public class Solution {
    public String getSmallestString(int n, int k) {
        int[] res = new int[n];
        Arrays.fill(res, 1);
        k -= n;
        int m = k / 25;
        k -= m * 25;
        for (int i = 0; i < m; i++) {
            res[n - 1 - i] = 26;
        }
        if (k != 0) res[n - 1 - m] += k;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append((char) ('a' - 1 + res[i]));
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.getSmallestString(5, 130);
    }
}
